<%@page pageEncoding="UTF-8" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
	<head>
		<title>部门信息修改</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<META HTTP-EQUIV="pragma" CONTENT="no-cache">         
		<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache,must-revalidate">         
		<META HTTP-EQUIV="expires" CONTENT="0">  
		<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
}
-->
</style>
	</head>
<base target="_self"/>
<% if(request.getAttribute("result")!=null && request.getAttribute("result").toString().equals("OK")) {%>
<script language="javascript">
//向父窗口返回的值
window.returnValue = "这是子窗口返回来的值,需要刷新父窗口";
window.close();
</script>
<% } %>
<jsp:include page="../common/init.jsp"></jsp:include>
	<script type="text/javascript">
//验证部门名称是否重复
function checkBmmc()
{
	var bmmc = document.forms[0].document.getElementsByName("appsysBmxx.bmmc")[0].value;
	var sjbmbh=document.forms[0].document.getElementsByName("appsysBmxx.sjbmbh")[0].value;
	var bmbh=document.forms[0].document.getElementsByName("appsysBmxx.bmbh")[0].value;
	var action=encodeURI("../servlet/CheckBmxx?validateFlag=bmxx&bmmc="+bmmc+"&sjbmbh="+sjbmbh+"&bmbh="+bmbh);
	var req = initRequest();
	req.open("post",action,false);
	req.send();
	return req.responseText;
}
var bmmcFlag=false;
var pxhFlag=false;
var bmmsFlag=false;
//验证部门名称
function validateBmmc(ajaxFlag)
{
	var checkId="appsysBmxx.bmmc";
	var checkValue=document.getElementById("appsysBmxx.bmmc").value;
	var errorDivId="bmmcDiv";
	var errorImgId="bmmcImg";
	if(checkNullValue(checkValue))
	{
		showMenuDelegate(checkId,errorDivId,errorImgId,"部门名称不能为空!");
		return false;
	}
	else if (checkValue.length>50)
	{
		showMenuDelegate(checkId,errorDivId,errorImgId,"用户名长度不能超过50个字!");
		return false;
	}
	else if (ajaxFlag=='b')
	{
		var flag=checkBmmc(); 
		if(flag=='yes')
		{
			showMenuDelegate(checkId,errorDivId,errorImgId,"部门名称已被用,请重新填写!");
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		hiddenErrorImg(errorImgId);
		return true;
	}
}
//验证排序号是否为数字
function validatePxh()
{	
	var checkId="appsysBmxx.pxh";
	var checkValue=document.getElementById("appsysBmxx.pxh").value;
	var errorDivId="pxhDiv";
	var errorImgId="pxhImg";
	if(checkNullValue(checkValue))
	{
		showMenuDelegate(checkId,errorDivId,errorImgId,"排序号不能为空!");
		return false;
	}
	else if(isNaN(checkValue))
	{
		showMenuDelegate(checkId,errorDivId,errorImgId,"排序号必须为正整数!");
		return false;
	}
	else
	{
		hiddenErrorImg(errorImgId);
		return true;
	}
}
//验证部门描述长度
function validateBmms()
{
	var checkId="eWebEditor1";
	var checkValue=document.getElementById("bmms").value;
	var errorDivId="bmmsDiv";
	var errorImgId="bmmsImg";
	if(checkValue.length>100)
	{
		showMenuDelegate(checkId,errorDivId,errorImgId,"部门描述不能超过100字!");
		return false;
	}
	else
	{
		hiddenErrorImg(errorImgId);
		return true;
	}
}
//选择上级部门
function selBmxx()
{
	var action="<%=request.getContextPath() %>/qxgl/selBmxx.do?tempid=" + Math.random()
	win = window.showModalDialog(action,null,'dialogHeight=450px;dialogWidth=310px;status=no;scroll=no;help=no');
    callback(win);	
}
function callback(rValue){
	if(rValue!=null)
	{
		bmxx=rValue;
		document.getElementById("sjbmbh").value=bmxx[0];
		document.getElementById("sjbmmc").value=bmxx[1];
	}
}
//提交
function doSubmit()
{
	bmmcFlag=validateBmmc('a');
	pxhFlag=validatePxh();
	bmmsFlag=validateBmms();
	if(bmmcFlag&&pxhFlag&&bmmsFlag)
	{
		document.forms[0].action="reworkBmxx.do";
		document.forms[0].submit();
	}
	else
	{
		return false;
	}
}
//页面关闭
function winClose()
{
	window.returnValue = "ok";
	window.close();
}
//表单reset
function formReset()
{
	document.forms[0].reset();
}
//提示信息
function showMessage(){
	var message="<%=request.getAttribute("info")%>";
	if(message != "null" && message != ""){
		document.getElementById('errorDivCreateWzbm').innerHTML='提示信息:<span style="font-size:12px;color:#ff0000">' + message + '</span>';
		document.getElementById('errorDivCreateWzbm').style.display="inline";
		document.getElementById('errorDivCreateWzbm').focus();
	}
}
//生成功能按钮	
mpmenu1=new mMenu('','winClose()','script','<%=request.getContextPath() %>/images/img_ht_wz_44.gif','62','24','0','100','2');
mpmenu2=new mMenu('','#','self','<%=request.getContextPath() %>/images/img_ht_wz_38.gif','62','24','0','20','0');
mpmenu3=new mMenu('','#','self','<%=request.getContextPath() %>/images/img_ht_wz_42.gif','62','24','0','20','0');
</script>
	<body onload="showMessage()">
<s:form action="">
<table cellspacing="0" cellpadding="0" class="main_tab1" onclick="javascript: mouseClick('errorDivCreateWzbm');">
    <tr>
        <td rowspan="4" class="main_tab1_td8">&nbsp;</td>
        <td class="main_tab1_td1"><img src="<%=request.getContextPath() %>/images/img_ht_wz_28.gif" alt="left" /></td>
        <td class="main_tab1_td2">
		<div id="location">部门信息修改</div>
		<div id="funbut">
			<SCRIPT>document.write(mwritetodocument());</SCRIPT>
		</div>
		</td>
        <td class="main_tab1_td1"><img src="<%=request.getContextPath() %>/images/img_ht_wz_32.gif" alt="right" /></td>
    </tr>
    <tr>
        <td colspan="3" class="main_tab1_td3">
		<div id="mainbg">
		<div class="jiange10"></div>
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="main_tab3">
				<tr valign="bottom" height="30">
					<td height="25" colspan="2" align="left" valign="bottom"
						class="r_tab_c_4">
						<div id="errorDivCreateWzbm"></div>&nbsp;
						<s:hidden name="appsysBmxx.id"/>
						<s:hidden name="appsysBmxx.bmbh"/>
						<s:hidden name="appsysBmxx.scbz"/>
						<s:hidden name="appsysBmxx.cjr"/>
						<s:hidden name="appsysBmxx.cjrq"/>
						<s:hidden name="appsysBmxx.ccs"/>
						<s:hidden name="appsysBmxx.bmgdbh"/>
					</td>
				</tr>
				<tr valign="bottom" align="center" height="30">
					<th align="right">
						部门名称：
					</th>
					<td align="left" >
					<s:textfield id="appsysBmxx.bmmc" name="appsysBmxx.bmmc" size="25" maxLength="50"
						theme="simple" onclick="javascript: mouseClick('bmmcDiv')" 
								onfocus="this.style.borderColor='#68A6F5'" onblur="validateBmmc('a');" cssClass="inp_02">
					</s:textfield>
						 &nbsp;
				<img src="" id="bmmcImg" style="display:none;"/>
				<div id="bmmcDiv" style="background:#008080;display:none;cursor:default"/>
					</td>
				</tr>
				<tr valign="bottom" height="30">
					<th align="right">
						上级部门：
					</th>
					<td >
					<s:hidden name="appsysBmxx.sjbmbh" id="sjbmbh" ></s:hidden>
					<s:textfield id="sjbmmc"  name="sjbmmc"  theme="simple" size="25" maxLength="50" cssClass="inp_02" disabled="true"/>
					&nbsp;
					<a href="javascript:void(0)" onfocus="this.blur()" >
					<img src="<%=request.getContextPath() %>/images/img_ht_wz_82.gif" border="0"  onclick="selBmxx();" ></a>
					</td>
				</tr>
				<tr valign="bottom" height="30">
					<th align="right">
						排序号：
					</th>
					<td align="left" valign="bottom">
						<s:textfield id="appsysBmxx.pxh" name="appsysBmxx.pxh"  size="2"
							maxLength="2" theme="simple" onclick="javascript: mouseClick('pxhDiv')" 
								onfocus="this.style.borderColor='#68A6F5'" onblur="validatePxh();" cssClass="inp_02">
					    </s:textfield>
						 &nbsp;
				        <img src="" id="pxhImg" style="display:none;"/>
				        <div id="pxhDiv" style="background:#008080;display:none;cursor:default"/>
					</td>
				</tr>
				<tr valign="bottom" >
					<th valign="center" align="right">
						部门描述：
					</th>
					<td onclick="javascript: mouseClick('bmmsDiv')">
					<s:textarea theme="simple" id="bmms" name="appsysBmxx.bmms" cols="35" rows="6"
							  onclick="javascript: mouseClick('bmmsDiv')" 
							  onfocus="this.style.borderColor='#68A6F5'" onblur="validateBmms();">
					    
					</s:textarea>
					<img src="" id="bmmsImg" style="display:none;"/>				
				    <div id="bmmsDiv" style="background:#008080;display:none;cursor:default"/>
					</td>
				</tr>
			</table>
<div class="butk">
<div class="btn_01">
<a href="#" onclick="doSubmit()">保&nbsp;存</a>
</div>
<div class="btn_01">
<a href="#" onclick="formReset()">清&nbsp;除</a>
</div>
</div>
</div>
</td>
    </tr>
    <tr>
        <td class="main_tab1_td4"><img src="<%=request.getContextPath() %>/images/img_ht_wz_65.gif" alt="left" /></td>
        <td class="main_tab1_td5"></td>
        <td class="main_tab1_td4"><img src="<%=request.getContextPath() %>/images/img_ht_wz_67.gif" alt="right" /></td>
    </tr>
    <tr>
        <td colspan="3" class="main_tab1_td7">&nbsp;</td>
    </tr>
</table>
<div id="Menu" style="background:#008080;display:none;cursor:default">
</div>
</s:form>
</body>
</html>